package com.qf.test6;

import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
import java.util.Map.Entry;

public class WorldCup {
	

	
	public static void main(String[] args) {
		
		
		HashMap<String, String> hashMap = new HashMap<String,String>();
		
		
		hashMap.put("1962", "巴西");
		hashMap.put("1966", "英格兰");
		hashMap.put("1970", "巴西");
		hashMap.put("1974", "德国");
		hashMap.put("1978", "阿根廷");
		hashMap.put("1982", "意大利");
		hashMap.put("1986", "阿根廷");
		hashMap.put("1990", "德国");
		hashMap.put("1994", "巴西");
		hashMap.put("1998", "法国");
		hashMap.put("2002", "巴西");
		hashMap.put("2006", "意大利");
		
		
		showAll(hashMap);
		
		Scanner input = new Scanner(System.in);
		System.out.println("请输入查询球队的名字：");
		String team = input.next();
		

		
		ShowYearByTeam(hashMap,team);
		
		
		
	}
	
	public static void showAll(HashMap<String ,String> hashMap) {
		Set<Entry<String, String>> entry = hashMap.entrySet();
		
		for (Entry<String, String> entry2 : entry) {
			System.out.println(entry2);
		}
		
	}
	
	public static void ShowYearByTeam(HashMap<String ,String> hashMap,String team) {
		
		Set<Entry<String, String>> entry = hashMap.entrySet();
		
		boolean flag =false;
		for (Entry<String, String> e : entry) {
			if(team.equals(e.getValue())) {
				System.out.println(e.getKey());
				flag=true;
			}
		}
		
		if(!flag) {
			System.out.println("该国家没有获得世界杯！");
		}
		
	}


}
